fix(docs): add id + name + visually-hidden <label> to docs search input (a11y)#145
Merged
Conversation
…ut (a11y)
UI-6 from the QA backlog (P3). The /docs sidebar search input shipped
with only an aria-label, failing the Lighthouse a11y rule "Form elements
must have labels". Password managers, form autofill, and screen readers
that prefer real <label htmlFor> over aria-label all degraded.
Fix:
- Add id="docs-search" + name="docs-search" to the <input>.
- Add a visually-hidden <label htmlFor="docs-search"> so the label
is discoverable by AT and Lighthouse without affecting visual layout.
- Keep the aria-label as a backstop (no harm, and a couple of older
AT versions still prefer it).
- Add a .visually-hidden CSS class — standard clip-rect pattern that
removes the element from the layout but leaves it in the a11y tree.
Regression coverage in DocsPage.test.tsx:
- input has id="docs-search" and name="docs-search"
- a <label> with for="docs-search" exists in the DOM and resolves to
the input
Verified: npm run gate green (1041 passed | 3 skipped).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
size-limit report 📦
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UI-6 from the QA backlog (P3). The
/docssidebar search input shipped with only anaria-label, failing the Lighthouse a11y rule "Form elements must have labels". Password managers, form autofill, and screen readers that prefer real<label htmlFor>overaria-labelall degraded.Fix
id="docs-search"+name="docs-search"to the<input>.<label htmlFor="docs-search">Search documentation</label>so the label is discoverable by AT and Lighthouse without affecting visual layout.aria-labelas a backstop (no harm, and a couple of older AT versions still prefer it)..visually-hiddenCSS class — standard clip-rect pattern that removes the element from the layout but leaves it in the a11y tree.Regression coverage
src/pages/DocsPage.test.tsx:id="docs-search"andname="docs-search"<label>withfor="docs-search"exists in the DOM and resolves to the input viahtmlForGate
npm run gategreen: 1041 passed | 3 skipped.Live verify (after merge)
🤖 Generated with Claude Code